<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href='https://fonts.googleapis.com/css?family=Architects+Daughter' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen">
<!-- <link rel="stylesheet" type="text/css" href="stylesheets/github-light.css" media="screen"> -->
<link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print">
<link rel="stylesheet" type="text/css" href="stylesheets/simple-calendar.css">

<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<title>SimpleCalendar.js日历插件 - 站长素材</title>
<style>
  #calendar{
	width: 100%
  }
  .clearfix{
	margin-bottom: 50px !important;
  }
</style>
</head>

<body>
<header>
  <div class="inner">
	<h1>Simple-calendar</h1>
	<h2>一个简单的日历插件</h2>
  </div>
</header>

<div id="content-wrapper">
<div class="inner clearfix">
  <div id = 'calendar'>

  </div>
</div>

  <div class="inner clearfix">
	<section id="main-content">
	  <h1>
<a id="simple-calendar开发文档" class="anchor" href="#simple-calendar%E5%BC%80%E5%8F%91%E6%96%87%E6%A1%A3" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Simple-Calendar开发文档</h1>

<hr>


<a id="引入资源" class="anchor" href="#%E5%BC%95%E5%85%A5%E8%B5%84%E6%BA%90" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>引入资源</h2>

<p>使用日历插件前首先要引用资源：JS CSS</p>

<div class="highlight highlight-source-js"><pre><span class="pl-k">&lt;</span>link rel<span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">"</span>stylesheet<span class="pl-pds">"</span></span> type<span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">"</span>text/css<span class="pl-pds">"</span></span> href<span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">"</span>css/simple-calendar.css<span class="pl-pds">"</span></span><span class="pl-k">&gt;</span>

<span class="pl-k">&lt;</span>script type<span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">"</span>text/javascript<span class="pl-pds">"</span></span> src<span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">"</span>js/simple-calendar.js<span class="pl-pds">"</span></span><span class="pl-k">&gt;&lt;</span><span class="pl-k">/</span>script<span class="pl-k">&gt;</span></pre></div>

<h2>
<a id="初始化一个日历" class="anchor" href="#%E5%88%9D%E5%A7%8B%E5%8C%96%E4%B8%80%E4%B8%AA%E6%97%A5%E5%8E%86" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>初始化一个日历</h2>

<p>首先为calendar准备一个容器，可以设置大小，也可以在options中设置，不设置的话自动设为默认</p>

<div class="highlight highlight-text-html-basic"><pre>  &lt;<span class="pl-ent">div</span> <span class="pl-e">id</span>=<span class="pl-s"><span class="pl-pds">'</span>container<span class="pl-pds">'</span></span>&gt;&lt;/<span class="pl-ent">div</span>&gt;</pre></div>

<div class="highlight highlight-text-html-basic"><pre><span class="pl-s1">  &lt;<span class="pl-ent">script</span>&gt;</span>
<span class="pl-s1">    <span class="pl-k">var</span> myCalendar <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">SimpleCalendar</span>(<span class="pl-s"><span class="pl-pds">'</span>#container<span class="pl-pds">'</span></span>);</span>
<span class="pl-s1">  &lt;/<span class="pl-ent">script</span>&gt;</span></pre></div>

<p>这样一个日历就诞生了 ^-^</p>

<h2>
<a id="配置项说明" class="anchor" href="#%E9%85%8D%E7%BD%AE%E9%A1%B9%E8%AF%B4%E6%98%8E" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>配置项说明</h2>

<div class="highlight highlight-source-js"><pre><span class="pl-k">var</span> options <span class="pl-k">=</span> {
  width<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>500px<span class="pl-pds">'</span></span>,
  height<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>500px<span class="pl-pds">'</span></span>,
  language<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>CH<span class="pl-pds">'</span></span>, <span class="pl-c">//语言</span>
  showLunarCalendar<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">//阴历</span>
  showHoliday<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">//休假</span>
  showFestival<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">//节日</span>
  showLunarFestival<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">//农历节日</span>
  showSolarTerm<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">//节气</span>
  showMark<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">//标记</span>
  timeRange<span class="pl-k">:</span> {
	startYear<span class="pl-k">:</span> <span class="pl-c1">1900</span>,
	endYear<span class="pl-k">:</span> <span class="pl-c1">2049</span>
  },
  mark<span class="pl-k">:</span> {
	<span class="pl-s"><span class="pl-pds">'</span>2016-5-5<span class="pl-pds">'</span></span><span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>上学<span class="pl-pds">'</span></span>
  },
  theme<span class="pl-k">:</span> {
	changeAble<span class="pl-k">:</span> <span class="pl-c1">false</span>,
	weeks<span class="pl-k">:</span> {
	  backgroundColor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>#FBEC9C<span class="pl-pds">'</span></span>,
	  fontColor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>#4A4A4A<span class="pl-pds">'</span></span>,
	  fontSize<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>20px<span class="pl-pds">'</span></span>,
	},
	days<span class="pl-k">:</span> {
	  backgroundColor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>#ffffff<span class="pl-pds">'</span></span>,
	  fontColor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>#565555<span class="pl-pds">'</span></span>,
	  fontSize<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>24px<span class="pl-pds">'</span></span>
	},
	todaycolor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>orange<span class="pl-pds">'</span></span>,
	activeSelectColor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>orange<span class="pl-pds">'</span></span>,
  }
}</pre></div>

<h3>
<a id="国际化" class="anchor" href="#%E5%9B%BD%E9%99%85%E5%8C%96" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>国际化</h3>

<blockquote>
<p>language：
语言的话目前只支持中文和英文，分别对应'CH','EN'</p>
</blockquote>

<p>如果想要加更多的语言或者更改现在的显示，可以直接更改languageData内容</p>

<h3>
<a id="节日显示配置" class="anchor" href="#%E8%8A%82%E6%97%A5%E6%98%BE%E7%A4%BA%E9%85%8D%E7%BD%AE" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>节日显示配置</h3>

<div class="highlight highlight-source-js"><pre>showLunarCalendar<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">//是否显示阴历日期</span>
showHoliday<span class="pl-k">:</span> <span class="pl-c1">true</span>,       <span class="pl-c">//是否显示休假休假</span>
showFestival<span class="pl-k">:</span> <span class="pl-c1">true</span>,      <span class="pl-c">//是否显示国际节日</span>
showLunarFestival<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">//是否显示农历节日</span>
showSolarTerm<span class="pl-k">:</span> <span class="pl-c1">true</span>,     <span class="pl-c">//是否显示节气</span>
showMark<span class="pl-k">:</span> <span class="pl-c1">true</span>,          <span class="pl-c">//是否显示标记日期</span>
</pre></div>

<h3>
<a id="时间范围" class="anchor" href="#%E6%97%B6%E9%97%B4%E8%8C%83%E5%9B%B4" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>时间范围</h3>

<p>这个时间范围设置的是下拉框中的年数范围</p>

<div class="highlight highlight-source-js"><pre>timeRange<span class="pl-k">:</span> {
startYear<span class="pl-k">:</span> <span class="pl-c1">1900</span>,
endYear<span class="pl-k">:</span> <span class="pl-c1">2049</span>
}</pre></div>

<h3>
<a id="标记日期" class="anchor" href="#%E6%A0%87%E8%AE%B0%E6%97%A5%E6%9C%9F" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>标记日期</h3>

<p>标记日期配置只有在 showMark 为 true 时才会生效</p>

<div class="highlight highlight-source-js"><pre>mark<span class="pl-k">:</span> {
	<span class="pl-s"><span class="pl-pds">'</span>2016-5-5<span class="pl-pds">'</span></span><span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>上学<span class="pl-pds">'</span></span>
  }</pre></div>

<p>这样就会在日历的对应日期上面添加标记，当鼠标停留时显示输入的信息</p>

<h3>
<a id="主题配置" class="anchor" href="#%E4%B8%BB%E9%A2%98%E9%85%8D%E7%BD%AE" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>主题配置</h3>

<div class="highlight highlight-source-js"><pre> theme<span class="pl-k">:</span> {
	changeAble<span class="pl-k">:</span> <span class="pl-c1">false</span>,
	weeks<span class="pl-k">:</span> {
	  backgroundColor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>#FBEC9C<span class="pl-pds">'</span></span>,
	  fontColor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>#4A4A4A<span class="pl-pds">'</span></span>,
	  fontSize<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>20px<span class="pl-pds">'</span></span>,
	},
	days<span class="pl-k">:</span> {
	  backgroundColor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>#ffffff<span class="pl-pds">'</span></span>,
	  fontColor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>#565555<span class="pl-pds">'</span></span>,
	  fontSize<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>24px<span class="pl-pds">'</span></span>
	},
	todaycolor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>orange<span class="pl-pds">'</span></span>,
	activeSelectColor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>orange<span class="pl-pds">'</span></span>,
  }</pre></div>

<p>主题配置只有在changeAble 为 true 时才会生效
weeks 设置的是星期一栏的主题，分别对应背景颜色，字体颜色，字体大小
days  设置的是日期的主题，参数同上
todaycolor 设置的是当天的日期背景颜色
activeSelectColor 设置的是鼠标滑过事件对应日期的边框颜色</p>

<h2>
<a id="事件接口说明" class="anchor" href="#%E4%BA%8B%E4%BB%B6%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>事件接口说明</h2>

<div class="highlight highlight-source-js"><pre><span class="pl-smi">myCalendar</span>.<span class="pl-en">updateSize</span>(<span class="pl-s"><span class="pl-pds">'</span>500px<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>500px<span class="pl-pds">'</span></span>);
<span class="pl-smi">myCalendar</span>.<span class="pl-en">addMark</span>(<span class="pl-s"><span class="pl-pds">'</span>2016-3-7<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>test<span class="pl-pds">'</span></span>);
<span class="pl-smi">myCalendar</span>.<span class="pl-en">setLanguage</span>(<span class="pl-s"><span class="pl-pds">'</span>EN<span class="pl-pds">'</span></span>)
<span class="pl-smi">myCalendar</span>.<span class="pl-en">showFestival</span>(<span class="pl-c1">false</span>);
<span class="pl-smi">myCalendar</span>.<span class="pl-en">showLunarCalendar</span>(<span class="pl-c1">false</span>);
<span class="pl-smi">myCalendar</span>.<span class="pl-en">showHoliday</span>(<span class="pl-c1">false</span>);
<span class="pl-smi">myCalendar</span>.<span class="pl-en">showSolarTerm</span>(<span class="pl-c1">false</span>);
<span class="pl-smi">myCalendar</span>.<span class="pl-en">showLunarFestival</span>(<span class="pl-c1">false</span>);
<span class="pl-smi">myCalendar</span>.<span class="pl-en">showMark</span>(<span class="pl-c1">false</span>);</pre></div>

<h3>
<a id="updatesizewidthheight" class="anchor" href="#updatesizewidthheight" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>updateSize(width,height)</h3>

<blockquote>
<p>调整日历大小，会自动根据大小调整对应的样式</p>
</blockquote>

<h3>
<a id="addmarkday-info" class="anchor" href="#addmarkday-info" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>addMark(day, info)</h3>

<blockquote>
<p>day   是一个可以确定一个日期的字符串
info  是要显示的信息</p>
</blockquote>

<h3>
<a id="setlenguagelanguagestr" class="anchor" href="#setlenguagelanguagestr" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>setLenguage(languageStr)</h3>

<blockquote>
<p>设置语言，目前支持的语言有'CH','EN'
如果想要增加语言，请在languageData中修改</p>
</blockquote>

<h3>
<a id="其他" class="anchor" href="#%E5%85%B6%E4%BB%96" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>其他</h3>

<div class="highlight highlight-source-js"><pre><span class="pl-c">//关闭或者显示国际节日</span>
<span class="pl-en">showFestival</span>(<span class="pl-c1">false</span>);
<span class="pl-c">//关闭或者显示阴历日期</span>
<span class="pl-en">showLunarCalendar</span>(<span class="pl-c1">false</span>);
<span class="pl-c">//关闭或者显示假期</span>
<span class="pl-en">showHoliday</span>(<span class="pl-c1">false</span>);
<span class="pl-c">//关闭或者显示二十四节气</span>
<span class="pl-en">showSolarTerm</span>(<span class="pl-c1">false</span>);
<span class="pl-c">//关闭或者显示阴历节日</span>
<span class="pl-en">showLunarFestival</span>(<span class="pl-c1">false</span>);
<span class="pl-c">//关闭或者显示标记</span>
<span class="pl-en">showMark</span>(<span class="pl-c1">false</span>)</pre></div>
	</section>

	
  </div>
</div>

<script type="text/javascript" src="javascripts/simple-calendar.js"></script>
<script>
 var myCalendar = new SimpleCalendar('#calendar');
</script>

<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">
<p>适用浏览器：360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗. 不支持IE8及以下浏览器。</p>
<p>来源：<a href="http://sc.chinaz.com/" target="_blank">站长素材</a></p>
</div>
</body>
</html>
